package com.cheyunkeji.er.adapter.evaluate;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.cheyun.netsalev3.R;
import com.cheyunkeji.er.adapter.MyBaseAdapter;
import com.cheyunkeji.er.bean.evaluate.CarInfo;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Michael on 2017/2/16 15:45.
 */

public class CarSourceCitySelecterAdapter extends MyBaseAdapter {

    public CarSourceCitySelecterAdapter(ArrayList<CarInfo.CarSourceCity> dataList, Context context) {
        super(dataList, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        final ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.er_car_source_city_selector_lv_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        if (position % 2 != 0)
            convertView.setBackgroundColor(Color.parseColor("#fbfbfb"));
        else
            convertView.setBackgroundColor(Color.parseColor("#ffffff"));

        CarInfo.CarSourceCity itemBean = (CarInfo.CarSourceCity) dataList.get(position);
        holder.tvCityName.setText(itemBean.getName());

        return convertView;

    }


    static class ViewHolder {
        @BindView(R.id.tv_city_name)
        TextView tvCityName;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
